#ifndef INPUT_H
#define INPUT_H

// Libraries
#include <irrlicht.h>
#include "singleton.h"

// Namespaces
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

// Classes
class InputClass : public IEventReceiver, public Singleton<InputClass>
{

	public:
	
		enum MouseButtonType {
			MOUSE_LEFT,
			MOUSE_RIGHT,
			MOUSE_MIDDLE,
			MOUSE_COUNT,
		};

		int Init();
		int Close();

		bool OnEvent(const SEvent &TEvent);

		void ResetInputState();
		bool GetKeyState(EKEY_CODE TKey) const { return Keys[TKey]; }
		bool GetMouseState(int TButton) const { return MouseButtons[TButton]; }

		const position2di &GetMousePosition() const { return MousePosition; }

		const char *GetKeyName(EKEY_CODE TKey);

		bool IsShiftDown() { return GetKeyState(KEY_SHIFT) || GetKeyState(KEY_LSHIFT) || GetKeyState(KEY_RSHIFT); }
		bool IsControlDown() { return GetKeyState(KEY_CONTROL) || GetKeyState(KEY_LCONTROL) || GetKeyState(KEY_RCONTROL); }

	private:

		void SetKeyState(EKEY_CODE TKey, bool TState) { Keys[TKey] = TState; }
		void SetMouseState(int TButton, bool TState) { MouseButtons[TButton] = TState; }

		// Input
		bool Keys[KEY_KEY_CODES_COUNT], MouseButtons[MOUSE_COUNT];
		position2di MousePosition;

};

#endif
